package com.hmall.order.web;

import com.hmall.order.pojo.Order;
import com.hmall.order.pojo.RequestParams;
import com.hmall.order.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
@Slf4j
public class OrderController {

   @Autowired
   private IOrderService orderService;

   @GetMapping("{id}")
   public Order queryOrderById(@PathVariable("id") Long orderId) {
      return orderService.getById(orderId);
   }

   /**
    * 创建订单
    * @param params
    * @return
    */
   @PostMapping
   public Long createOrder(@RequestBody RequestParams params){
      Long id = orderService.createOrder(params);
      //打印日志信息
      log.info("id={}",id);
      return id;



   }
}
